﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:local="clr-namespace:MainGameModule.Views"
             xmlns:converters="clr-namespace:MainGameModule.Views.Converters"
             xmlns:controls="clr-namespace:MainGameModule"
             xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
             xmlns:System="clr-namespace:System;assembly=mscorlib"
             xmlns:ec="http://schemas.microsoft.com/expression/2010/controls"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             x:Class="MainGameModule.Views.GameMainView">

    <UserControl.Resources>
        <ResourceDictionary>

            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/YourWorld.Common;component/Styles/CommonResourcesDictionary.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <converters:GameObjectToViewConverter x:Key="GameObjectToViewConverter" />

            <ec:IsArrangedToScaleConverter x:Key="IsArrangedToScaleConverter" />
            <Style x:Key="PathListBoxItemStyle"
                   TargetType="ec:PathListBoxItem">
                <Setter Property="HorizontalContentAlignment"
                        Value="Left" />
                <Setter Property="VerticalContentAlignment"
                        Value="Top" />
                <Setter Property="Background"
                        Value="Transparent" />
                <Setter Property="BorderThickness"
                        Value="1" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ec:PathListBoxItem">
                            <Grid Background="{TemplateBinding Background}"
                                  RenderTransformOrigin="0.5,0.5">
                                <Grid.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform ScaleY="{Binding IsArranged, Converter={StaticResource IsArrangedToScaleConverter}, RelativeSource={RelativeSource TemplatedParent}}"
                                                        ScaleX="{Binding IsArranged, Converter={StaticResource IsArrangedToScaleConverter}, RelativeSource={RelativeSource TemplatedParent}}" />
                                        <SkewTransform />
                                        <RotateTransform Angle="{Binding OrientationAngle, RelativeSource={RelativeSource TemplatedParent}}" />
                                        <TranslateTransform />
                                    </TransformGroup>
                                </Grid.RenderTransform>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal" />
                                        <VisualState x:Name="MouseOver" />
                                        <VisualState x:Name="Disabled" />
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="SelectionStates">
                                        <VisualState x:Name="Unselected" />
                                        <VisualState x:Name="Selected" />
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="FocusStates">
                                        <VisualState x:Name="Focused" />
                                        <VisualState x:Name="Unfocused" />
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Rectangle x:Name="fillColor"
                                           Fill="#FFBADDE9"
                                           IsHitTestVisible="False"
                                           Opacity="0"
                                           RadiusY="1"
                                           RadiusX="1" />
                                <Rectangle x:Name="fillColor2"
                                           Fill="#FFBADDE9"
                                           IsHitTestVisible="False"
                                           Opacity="0"
                                           RadiusY="1"
                                           RadiusX="1" />
                                <ContentPresenter x:Name="contentPresenter"
                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  Content="{TemplateBinding Content}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  Margin="{TemplateBinding Padding}" />
                                <Rectangle x:Name="FocusVisualElement"
                                           RadiusY="1"
                                           RadiusX="1"
                                           Stroke="#FF6DBDD1"
                                           StrokeThickness="1"
                                           Visibility="Collapsed" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="BusyIndicatorStyle"
                   TargetType="toolkit:BusyIndicator">
                <Setter Property="BusyContent"
                        Value="Please wait..." />
                <Setter Property="IsTabStop"
                        Value="False" />
                <Setter Property="OverlayStyle">
                    <Setter.Value>
                        <Style TargetType="Rectangle">
                            <Setter Property="Fill"
                                    Value="White" />
                            <Setter Property="Opacity"
                                    Value="0.5" />
                        </Style>
                    </Setter.Value>
                </Setter>
                <Setter Property="ProgressBarStyle">
                    <Setter.Value>
                        <Style TargetType="ProgressBar">
                            <Setter Property="IsIndeterminate"
                                    Value="True" />
                            <Setter Property="Height"
                                    Value="15" />
                            <Setter Property="Margin"
                                    Value="8,0,8,8" />
                        </Style>
                    </Setter.Value>
                </Setter>
                <Setter Property="DisplayAfter"
                        Value="00:00:00.1" />
                <Setter Property="HorizontalAlignment"
                        Value="Stretch" />
                <Setter Property="VerticalAlignment"
                        Value="Stretch" />
                <Setter Property="HorizontalContentAlignment"
                        Value="Stretch" />
                <Setter Property="VerticalContentAlignment"
                        Value="Stretch" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="toolkit:BusyIndicator">
                            <Grid>
                                <Grid.Resources>
                                    <Storyboard x:Name="RotateLeavesStoryboard"
                                                RepeatBehavior="Forever"
                                                AutoReverse="False">
                                        <DoubleAnimation Duration="0:0:2"
                                                         To="1"
                                                         Storyboard.TargetProperty="(PathListBox.LayoutPaths)[0].(LayoutPath.Span)"
                                                         Storyboard.TargetName="pathListBox" />
                                        <DoubleAnimation Duration="0:0:2"
                                                         To="1"
                                                         Storyboard.TargetProperty="(PathListBox.LayoutPaths)[0].(LayoutPath.Start)"
                                                         Storyboard.TargetName="pathListBox" />
                                    </Storyboard>
                                </Grid.Resources>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="VisibilityStates">
                                        <VisualState x:Name="Hidden">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                               Duration="00:00:00.001"
                                                                               Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                               Storyboard.TargetName="busycontent">
                                                    <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Collapsed</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                               Duration="00:00:00.001"
                                                                               Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                               Storyboard.TargetName="overlay">
                                                    <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Collapsed</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Visible">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                               Duration="00:00:00.001"
                                                                               Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                               Storyboard.TargetName="busycontent">
                                                    <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Visible</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                               Duration="00:00:00.001"
                                                                               Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                               Storyboard.TargetName="overlay">
                                                    <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Visible</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="BusyStatusStates">
                                        <VisualState x:Name="Idle">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                               Duration="00:00:00.001"
                                                                               Storyboard.TargetProperty="(Control.IsEnabled)"
                                                                               Storyboard.TargetName="content">
                                                    <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <System:Boolean>True</System:Boolean>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Busy">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                               Duration="00:00:00.001"
                                                                               Storyboard.TargetProperty="(Control.IsEnabled)"
                                                                               Storyboard.TargetName="content">
                                                    <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <System:Boolean>False</System:Boolean>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <ContentControl x:Name="content"
                                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                                Content="{TemplateBinding Content}"
                                                HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
                                <Rectangle x:Name="overlay"
                                           Style="{TemplateBinding OverlayStyle}" />
                                <ContentPresenter x:Name="busycontent">
                                    <i:Interaction.Triggers>
                                        <ei:PropertyChangedTrigger Binding="{Binding Visibility, ElementName=busycontent}">
                                            <ei:ControlStoryboardAction Storyboard="{StaticResource RotateLeavesStoryboard}" />
                                        </ei:PropertyChangedTrigger>
                                    </i:Interaction.Triggers>
                                    <Grid HorizontalAlignment="Center"
                                          VerticalAlignment="Center">
                                        <Border BorderThickness="1"
                                                CornerRadius="2">
                                            <Border CornerRadius="1.5"
                                                    Margin="1"
                                                    Opacity="0.995">
                                                <Grid MinWidth="150"
                                                      Height="150"
                                                      Width="151">
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition />
                                                        <RowDefinition Height="Auto" />
                                                    </Grid.RowDefinitions>
                                                    <ContentPresenter ContentTemplate="{TemplateBinding BusyContentTemplate}"
                                                                      Content="{TemplateBinding BusyContent}"
                                                                      Margin="8"
                                                                      VerticalAlignment="Bottom" />
                                                    <ec:PathListBox x:Name="pathListBox"
                                                                    Margin="-13,-14,0,0"
                                                                    HorizontalAlignment="Left"
                                                                    Height="15"
                                                                    VerticalAlignment="Top"
                                                                    Width="13"
                                                                    ItemContainerStyle="{StaticResource PathListBoxItemStyle}">
                                                        <ec:PathListBox.LayoutPaths>
                                                            <ec:LayoutPath SourceElement="{Binding ElementName=rode}" />
                                                        </ec:PathListBox.LayoutPaths>
                                                        <Image Height="30"
                                                               Width="30"
                                                               Source="images/papaya leaf.png" />
                                                        <Image Height="30"
                                                               Width="30"
                                                               Source="images/leaf (1).png" />
                                                        <Image Height="30"
                                                               Width="30"
                                                               Source="images/leaf (2).png" />
                                                        <Image Height="30"
                                                               Width="30"
                                                               Source="images/Birch leaf.png" />
                                                    </ec:PathListBox>
                                                    <Path x:Name="rode"
                                                          Data="M16,50 C76,47 37.999763,117.00198 89.999763,96.001984 C141.99976,75.001984 128.99968,104.00284 122,54.99995 C111.8885,-15.788024 77.999832,-10.002843 68.999832,34.99947"
                                                          Margin="15.5,0.916,20.757,49.564"
                                                          Stretch="Fill"
                                                          UseLayoutRounding="False"
                                                          StrokeThickness="2" />
                                                </Grid>
                                            </Border>
                                        </Border>
                                    </Grid>
                                </ContentPresenter>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Storyboard x:Name="flickStoryboard">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                               Storyboard.TargetName="ExperiencePopUp">
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.1">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.7">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                    <DiscreteObjectKeyFrame KeyTime="0:0:1.1">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                    <DiscreteObjectKeyFrame KeyTime="0:0:1.6">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                    <DiscreteObjectKeyFrame KeyTime="0:0:2">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                    <DiscreteObjectKeyFrame KeyTime="0:0:2.3">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Collapsed</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                    <DiscreteObjectKeyFrame KeyTime="0:0:2.5">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Collapsed</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                               Storyboard.TargetName="ExperiencePopUp">
                    <EasingDoubleKeyFrame KeyTime="0:0:0.7"
                                          Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:1.1"
                                          Value="0.750015" />
                    <EasingDoubleKeyFrame KeyTime="0:0:1.6"
                                          Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:2"
                                          Value="0.428571" />
                    <EasingDoubleKeyFrame KeyTime="0:0:2.3"
                                          Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:2.5"
                                          Value="1" />
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)"
                                               Storyboard.TargetName="ExperiencePopUp">
                    <EasingDoubleKeyFrame KeyTime="0:0:1.1"
                                          Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:1.6"
                                          Value="1.2" />
                    <EasingDoubleKeyFrame KeyTime="0:0:2"
                                          Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:2.3"
                                          Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:2.5"
                                          Value="1" />
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)"
                                               Storyboard.TargetName="ExperiencePopUp">
                    <EasingDoubleKeyFrame KeyTime="0:0:1.1"
                                          Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:1.6"
                                          Value="1.2" />
                    <EasingDoubleKeyFrame KeyTime="0:0:2"
                                          Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:2.3"
                                          Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:2.5"
                                          Value="1" />
                </DoubleAnimationUsingKeyFrames>

            </Storyboard>
            <Storyboard x:Name="ShowLevelFinishedPopUp">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                               Storyboard.TargetName="LevelFinishedPopUp">
                    <EasingDoubleKeyFrame KeyTime="0"
                                          Value="0" />
                    <EasingDoubleKeyFrame KeyTime="0:0:1"
                                          Value="0.9" />
                </DoubleAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                               Storyboard.TargetName="WellDoneLabel">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Collapsed</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                    <DiscreteObjectKeyFrame KeyTime="0:0:1">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                               Storyboard.TargetName="WellDoneLabel">
                    <EasingDoubleKeyFrame KeyTime="0"
                                          Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:1"
                                          Value="0" />
                    <EasingDoubleKeyFrame KeyTime="0:0:2"
                                          Value="1" />
                </DoubleAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                               Storyboard.TargetName="LevelFinishedPopUp">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                    <DiscreteObjectKeyFrame KeyTime="0:0:7">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Collapsed</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>

        </ResourceDictionary>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot"
          Margin="0,20,0,0">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="VisualStateGroup">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:0.5">
                        <VisualTransition.GeneratedEasingFunction>
                            <CircleEase EasingMode="EaseOut" />
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="NormalState" />
                <VisualState x:Name="InfoState">
                    <Storyboard>
                        <DoubleAnimation Duration="0"
                                         To="1"
                                         Storyboard.TargetProperty="(UIElement.Opacity)"
                                         Storyboard.TargetName="InfoGrid"
                                         d:IsOptimized="True" />
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="InfoGrid">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <toolkit:BusyIndicator IsBusy="{Binding IsBusy}"
                               Style="{StaticResource BusyIndicatorStyle}">

            <Grid>
                <ScrollViewer x:Name="gameScrollviewer"
                              BorderThickness="0"
                              Padding="0"
                              DragOver="gameScrollviewer_DragOver"
                              KeyDown="mainGamePanel_KeyDown"
                              HorizontalScrollBarVisibility="Hidden"
                              VerticalScrollBarVisibility="Hidden"
                              VerticalAlignment="Stretch"
                              HorizontalAlignment="Stretch">

                        <ItemsControl x:Name="mainGamePanelItems"
                                      RenderTransformOrigin="0.5,0.5"
                                      IsEnabled="{Binding IsIdle}"
                                      ItemsSource="{Binding GameObjectsCollection}">
                            <ItemsControl.RenderTransform>
                                <ScaleTransform ScaleY="-1" />
                            </ItemsControl.RenderTransform>

                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <local:MainPanel x:Name="MainGamePanel"
                                                     Width="4000"
                                                     Height="4000"
                                                     Margin="0"
                                                     HorizontalAlignment="Stretch"
                                                     VerticalAlignment="Stretch"
                                                     RenderTransformOrigin="0.5,0.5">
                                        <local:MainPanel.Background>
                                            <ImageBrush ImageSource="../Images/objects/mapClean.jpg"
                                                        Stretch="UniformToFill" />
                                        </local:MainPanel.Background>
                                        <local:MainPanel.RenderTransform>
                                            <ScaleTransform x:Name="ItemsScaleTransform"
                                                            ScaleY="1"
                                                            ScaleX="1" />
                                        </local:MainPanel.RenderTransform>
                                    </local:MainPanel>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>

                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <ContentPresenter Content="{Binding Converter={StaticResource GameObjectToViewConverter}}" />
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>

                        </ItemsControl>
                       
                </ScrollViewer>

                <Button x:Name="TestButton"
                        Opacity="0"
                        Width="10"
                        Height="10"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Bottom" />

                <Grid x:Name="ExperiencePopUp"
                      Width="200"
                      Height="200"
                      Opacity="0"
                      Visibility="Collapsed"
                      RenderTransformOrigin="0.5,0.5">
                    <Grid.RenderTransform>
                        <CompositeTransform />
                    </Grid.RenderTransform>
                    <Image Source="images/exp.png"
                           Width="200"
                           Height="200" />
                </Grid>
                
                <Grid x:Name="LevelFinishedPopUp"
                      Visibility="Collapsed"
                      Width="680"
                      Height="200">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="200" />
                        <ColumnDefinition Width="300" />
                    </Grid.ColumnDefinitions>
                    <TextBlock  x:Name="LevelLabel"
                                Text="Level"
                                Grid.Column="0"
                                FontSize="65"
                                FontFamily="Fonts/ArbuckleInlineNF.ttf#Arbuckle Inline NF, Verdana"
                                Foreground="White"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center" />
                    <TextBlock  x:Name="WellDoneLabel"
                                Text="Well done"
                                Grid.Column="2"
                                FontSize="65"
                                FontFamily="Fonts/ArbuckleInlineNF.ttf#Arbuckle Inline NF, Verdana"
                                Foreground="White"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center" />
                    <Ellipse x:Name="LevelEllipse"
                             Grid.Column="1"
                             Width="200"
                             Height="200"
                             Stroke="#FFE7E7E7"
                             StrokeThickness="4"
                             Opacity="0.895"
                             Fill="#FF257607" />
                    <TextBlock  x:Name="Level"
                                Grid.Column="1"
                                FontSize="180"
                                FontFamily="Fonts/ArbuckleInlineNF.ttf#Arbuckle Inline NF, Verdana"
                                Foreground="White"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center" />
                </Grid>

                <Grid x:Name="InfoGrid"
                      Width="400"
                      Height="250"
                      Opacity="0"
                      Visibility="Collapsed">

                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Path Grid.RowSpan="2"
                          Data="M187.2383,141.7393C187.2383,141.7393,176.3913,144.7943,172.5713,149.0723C164.2383,158.4063,166.5713,209.7393,165.2383,221.7393C163.9053,233.7393,163.9053,364.4073,165.2383,397.0733C166.5713,429.7393,165.2383,441.7393,167.9053,452.4053C170.5713,463.0733,178.5713,462.4053,187.2383,465.7393C195.9053,469.0733,317.9053,475.0733,335.2383,475.0733C352.5713,475.0733,497.2383,476.4073,523.9053,475.0733C550.5723,473.7393,617.2393,476.4053,630.5723,469.7393C643.9053,463.0733,651.2383,452.4053,651.2383,435.7393C651.2383,419.0733,652.5713,301.0723,651.2383,249.0723C649.9053,197.0723,651.8313,159.3863,645.9053,150.4063C641.9333,144.3863,629.2383,143.7393,617.9053,141.7393C606.5723,139.7393,419.9053,137.7393,381.2383,138.4063C342.5713,139.0723,187.2383,141.7393,187.2383,141.7393z"
                          Stretch="Fill">
                        <Path.Effect>
                            <DropShadowEffect />
                        </Path.Effect>
                        <Path.Fill>
                            <RadialGradientBrush RadiusX="0.8">
                                <GradientStop Color="#FFD1E778" />
                                <GradientStop Color="#FF4A6305"
                                              Offset="1" />
                            </RadialGradientBrush>
                        </Path.Fill>
                    </Path>

                    <TextBlock x:Name="InfoText"
                               Grid.Row="0"
                               Margin="10"
                               FontFamily="Segoa UI"
                               FontSize="12"
                               Foreground="White"
                               TextAlignment="Center"
                               TextWrapping="Wrap"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center" />

                    <Button Grid.Row="1"
                            x:Name="CloseMeButton"
                            VerticalAlignment="Center"
                            Content=" OK "
                            Style="{StaticResource GwButtonStyle}"
                            Margin="20"
                            HorizontalAlignment="Center">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <ei:GoToStateAction StateName="NormalState" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>

                </Grid>

            </Grid>
        </toolkit:BusyIndicator>
    </Grid>

</UserControl>
